#ifndef AVIATION_DATE_H
#define AVIATION_DATE_H

#include "util.h"

#include <string>

#include <boost/serialization/nvp.hpp>

namespace aviation
{
/// Represents a date in ddmmyyyy format.
class Date
{
public:

	typedef std::string String;

	//Constructors

	//Initialises date.
	Date();

	/// Constructs a Date from the relevant part of a line from an FCGDATA file.
	Date(const String& fcgString);

	/// Copies the date from another.
	Date(const Date& other);

	/// Destructs the date.
	~Date();

	/// Serialization (file I-O) function.
	/// \param ar A boost::archive formatter type.
	/// \param version The file version.
	template <class Archive>
	void serialize(Archive& ar, const unsigned int version);

	//Operators

	/// Assigns the content of one date to another.
	Date& operator=(const Date& other);

	/// Tests for equality between two dates.
	/// \returns True if they are the same and false if they are different.
	const bool operator==(const Date& other) const;

	/// Tests for inequality between two dates.
	/// \returns True if they are different and false if they are the same.
	const bool operator!=(const Date& other) const;

	/// \returns True if one date is strictly less than another.
	const bool operator<(const Date& other) const;

	// Accessors

	/// Gets the day as an integer.
	const unsigned int GetDay() const;

	/// Gets the month as an integer.
	const unsigned int GetMonth() const;

	/// Gets the year as an integer.
	const unsigned int GetYear() const;

	/// Gets the date as a string.
	const String AsString() const;

private:

	unsigned int m_day;
	unsigned int m_month;
	unsigned int m_year;
};

template <class Archive>
void Date::serialize(Archive& ar, const unsigned int version)
{
	ar & BOOST_SERIALIZATION_NVP(m_day);
	ar & BOOST_SERIALIZATION_NVP(m_month);
	ar & BOOST_SERIALIZATION_NVP(m_year);
}

} // namespace aviation

#endif // AVIATION_DATE_H